package com.qding.park.manager.web.controller;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qding.park.common.core.validate.RchlValidateBean;
import com.qding.park.common.core.validate.RchlValidateTools;
import com.qding.park.common.utils.DateUtils;
import com.qding.park.common.web.controller.BaseController;
import com.qding.park.manager.common.pojo.ParkDataResult;
import com.qding.park.manager.common.rest.domain.AnswerMsg;
import com.qding.park.manager.common.rest.domain.AnswerMsgFactoryImpl;
import com.qding.park.manager.facade.statis.service.LogStatisFacade;
import com.qding.park.manager.pojo.example.NcPresenExample;

@RestController
@RequestMapping("/log")
public class Web_LogController extends BaseController {
	
    private static final Logger _log = LoggerFactory.getLogger(Web_LogController.class);
	
	@Autowired
	private  LogStatisFacade  logStatisFacade;
	
	
//	@SystemControllerLog(description="系统操作日志查询",operation=OperationLogType.log_operationLog_list)
	@RequestMapping("/operationLog/list")
	public AnswerMsg operationLog_list(String jumpPage, String pageLength,String startTime,String endTime){
		/****** 验证字段 ********/
		RchlValidateBean vb = new RchlValidateBean();
		vb.getRequiredValidate().put("jumpPage", jumpPage);
		vb.getRequiredValidate().put("pageLength", pageLength);
		// vb.getRequiredValidate().put("carNum", carNum);
		
		vb.getIntValidate().put("jumpPage", jumpPage);
		vb.getIntValidate().put("pageLength", pageLength);
		RchlValidateTools.validate(vb);
		/**************/
		
		NcPresenExample  example=new NcPresenExample();
		if (!StringUtils.isBlank(startTime)) {
			// 缴费开始时间
			example.setStartTime(DateUtils.parseDate(startTime, DateUtils.DATE_FORMAT_DATETIME));
		}
		if (!StringUtils.isBlank(endTime)) {
			// 缴费开始时间
			example.setEndTime(DateUtils.parseDate(endTime,DateUtils.DATE_FORMAT_DATETIME));
		}
		
		int jumpPageInt = Integer.valueOf(jumpPage);
		int pageLengthInt = Integer.valueOf(pageLength);
		
		ParkDataResult dataResult = logStatisFacade.operationLoglist(example,jumpPageInt,pageLengthInt);
		AnswerMsg answerMsg = AnswerMsgFactoryImpl.createAnswerMsg(dataResult.getData());
		return answerMsg;
	}

}
